home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / vmsnet / snake / part02 < prev   
Encoding:
Internet Message Format  |  1992-02-26  |  19.0 KB

  1. Path: uunet!wupost!waikato.ac.nz!ccc_rex
  2. From: ccc_rex@waikato.ac.nz
  3. Newsgroups: vmsnet.sources.games
  4. Subject: SNAKE 2/2
  5. Message-ID: <1992Feb27.143424.6696@waikato.ac.nz>
  6. Date: 27 Feb 92 14:34:23 +1300
  7. Organization: University of Waikato, Hamilton, New Zealand
  8. Lines: 583
  9.  
  10. -+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
  11. X   Write(esc,'Y',chr(31+X),Chr(31+Y));
  12. X   at := Chr(0);
  13. Xend;
  14. X
  15. X
  16. XFunction Snake_Init(Var You :  INteger ; Var Game_going : Integer):Integer;e
  17. Vxtern;
  18. X
  19. XProcedure Name_Set(Var Name : Name_Line );extern;
  20. X
  21. XProcedure Name_Get( VAR Name : Name_Line ; Play : Integer );extern;
  22. X
  23. XProcedure Score_Set( Player : INTEGER; VAR Score,Games_PLayed,wins : INteger
  24. V);
  25. X`09`09`09`09`09`09`09extern;
  26. XProcedure Score_Get( Player : INTEGER; VAR Score,Games_Played,wins : Integer
  27. V );
  28. X`09`09`09`09`09`09`09extern;
  29. XProcedure Snake_Start( Var Whos_PLaying : Integer ; var Rand : Positions );E
  30. Vxtern;
  31. X
  32. XProcedure Snake_Read(Var Directions : Player_Responce );Extern;
  33. X
  34. XProcedure Snake_Game_End;extern;
  35. X
  36. XProcedure Snake_Wait;Extern;
  37. X
  38. XProcedure Snake_Game_count( Var Num : Integer);extern;
  39. X
  40. XProcedure Snake_Dead(Var PLayer : Integer );extern;
  41. X
  42. XProcedure Sleep( Num_Sec : Integer);extern;
  43. X
  44. XProcedure Draw_Scores;
  45. X
  46. XVar I,num_on_table,play,max_score,Top_play,Total_Num_Games,This_score: Integ
  47. Ver;
  48. X
  49. X
  50. XBegin
  51. X   Num_on_Table := 0;
  52. X   Writeln(esc,'H',Esc,'J',Esc,'G',esc,'<');
  53. X   Writeln(' Player   User         Name               Score  Game  Won   Gra
  54. Vph');
  55. X   writeln(' ------   ----         ----               -----  ----  ---   ---
  56. V--');
  57. X   writeln;
  58. X   Max_score := -99999;
  59. X
  60. X   `7B Find The Top Player  goes By The his Score And Num Of Games Played `7
  61. VD
  62. X   For PLay := 1 to Max_Num_PLayers do  begin
  63. X      Score_get(Play,Score`5BPLay`5D,Game`5BPLay`5D,Games_won`5Bplay`5D);
  64. X      If Game`5BPlay`5D > 0 Then Begin
  65. X         This_score := Round(Score`5Bplay`5D / (Game`5Bplay`5D)**(0.8));
  66. X         If This_score > Max_score Then Begin
  67. X            Top_Play := Play;
  68. X            Max_score := This_score + 1;
  69. X         end;
  70. X      end;
  71. X   end;
  72. X   For Play := 1 to Max_Num_PLayers do Begin
  73. X      If Game`5BPLay`5D > 0  Then Begin   `7B IF Games PLayed > 0 Then You A
  74. Vre PLaying  `7D
  75. X         Num_On_Table := Num_On_Table + 1;
  76. X         If PLay = Top_PLay Then`20
  77. X            Write(esc,'`5B1m');  `7B High intensity Flash `7D
  78. X         Write(Play:4);
  79. X         Write('    ',Name`5BPlay`5D:32);
  80. X         write(Score`5BPLay`5D:7);         `7B Print Info `7D
  81. X         Write(Game`5BPlay`5D:6);
  82. X         Write(Games_won`5Bplay`5D:5);
  83. X         Write('   ',Esc,'`5B7m'); `7B Rev Video `7D
  84. X         If PLay = Top_PLay Then   `20
  85. X             Write(' *** Champ *** ')
  86. X      `09 Else
  87. X            For I := 1 to Round(Score`5Bplay`5D*15 / ((Game`5Bplay`5D)**(0.8
  88. V)*max_score)) do`20
  89. X               Write(' ');
  90. X         Writeln(esc,'`5B0m'); `7B Normal Video `7D
  91. X      end;
  92. X    End;
  93. X   writeln;
  94. X
  95. X`7B Print The Games You Have Played With The Totak Num of Games Played so Fa
  96. Vr `7D
  97. X   Snake_Game_Count( Total_Num_games );
  98. X   Writeln(' Game # ',Game`5BYou`5D:1,'`09Total # ',Total_Num_Games:1);
  99. X   writeln;
  100. X   writeln;
  101. X   If Num_on_Table <= 1 Then`20
  102. X      Goto 9999;
  103. X   writeln(' Please Wait For Next Game ..... ');
  104. X   writeln(esc,'`5B?2l',esc,'F');
  105. Xend;
  106. X
  107. XProcedure Draw_screen;
  108. X
  109. XVar play,I,X,Y,Line_at : Integer;
  110. X
  111. X   Function Min(A,B:Integer):Integer;
  112. X
  113. X   Begin
  114. X      If A < B Then`20
  115. X         Min := A`20
  116. X      Else
  117. X         Min := B
  118. X   end;
  119. X
  120. XBegin `7B Draw Screen `7D
  121. X   Write(at(1,1),esc,'J',esc,'<',esc,'(0',esc,'<',esc,'(0');     `7B Clear H
  122. Vome `7D
  123. X   Write(esc,'#6l');
  124. X   For Y := 1 To (Screen_Dim_Y-2) Do`20
  125. X      Write('q');
  126. X   Writeln('k');
  127. X   For X := 2 To ( Screen_dim_X - 1 )  Do begin
  128. X      Write(esc,'#6x');
  129. X      For Y := 1 to (Screen_Dim_Y-1) do`20
  130. X         Write('`7E');
  131. X      Writeln('x');
  132. X   end;
  133. X   write(esc,'#6m');
  134. X   For Y := 1 to (Screen_Dim_Y-1) Do`20
  135. X      Write('q');
  136. X   Writeln('j');
  137. X
  138. X`7B   Show Who You Are At Thje Bottom Of The Screen  `7D
  139. X   Writeln(`7BEsc,'`5B24;1H',Esc,'#6',Esc,'(BYou # ',You:1,`7D
  140. X`09      esc,'`5B?2l',esc,'F',at(1,1));  `20
  141. Xend;
  142. X
  143. X  `20
  144. XProcedure initalise_Positions;
  145. X
  146. X
  147. X
  148. XVar Mult,Play,X,Y : Integer;
  149. X
  150. X    Rand`09  : Positions;
  151. X
  152. XBegin
  153. X
  154. XPlayers_Removing := -1;  `7B On First Few Moves Don't remove Tail `7D
  155. X
  156. XSnake_Start(Who_Is_Playing,Rand);
  157. X
  158. X
  159. X`7B Randomly Position The Starting Pos Of The PLayers `7D
  160. XFor play := 1 to Max_num_players do  Begin
  161. X   Head_X`5BPlay`5D := Init_Pos_X`5BRand`5BPlay`5D`5D;
  162. X   Head_Y`5Bplay`5D := Init_Pos_Y`5BRand`5BPLay`5D`5D;
  163. X   Move_X`5Bplay`5D := 1;
  164. X   MOve_Y`5BPlay`5D := 0;
  165. Xend;
  166. XTail_X := Head_X;
  167. XTail_Y := Head_Y;
  168. X
  169. XMult := 2**7;  `7B 2 ** Number of PLayers - 1`7D
  170. XNum_Players := 0;
  171. X
  172. X`7B Examine Each Bit In Mult To See If You Are Playing `7D
  173. XMax_player_number := 0;
  174. XFor Play := Max_Num_PLayers downto 1 do begin
  175. X   If ( Who_Is_PLaying div Mult ) = 1 Then begin
  176. X      Name_Get(Name`5BPlay`5D,Play);
  177. X      Num_Players := Num_PLayers + 1;
  178. X      Quit`5Bplay`5D := False;   `7B Bit Set You Are Playing `7D
  179. X      Who_is_Playing := Who_is_Playing - Mult;
  180. X      If Max_player_number = 0 Then`20
  181. X         Max_player_number := play ;`7B The Highest Numbered Player `7D
  182. X   end else begin
  183. X      Quit`5BPlay`5D := True;   `7B Bit Not Set Not Playing ie Quit `7D
  184. X   end;
  185. X   Mult := Mult div 2;
  186. Xend;
  187. X
  188. XNum_Moved_Last_Round := 0;
  189. X
  190. X`7B If You are PLaying Then You Havnt Died `7D
  191. XFor Play := 1 to Max_Num_Players Do  Begin
  192. X   If Not Quit`5BPlay`5D Then Begin
  193. X      Died`5BPlay`5D := False;
  194. X      Num_Moved_Last_Round := Num_Moved_Last_Round + 1;
  195. X   end else
  196. X      Died`5Bplay`5D := True;
  197. X   responce`5BPlay`5D := ' ';   `7B Initalise First Responce Should Not BE N
  198. Veeded `7D
  199. Xend;
  200. XFor PLay := 1 to Max_Num_PLayers do`20
  201. X   Game`5BPLay`5D :=   Game`5BPLay`5D + 1;
  202. XFor X := 1 To Screen_Dim_X do`20
  203. X   For Y := 1 to Screen_Dim_Y do
  204. X      Screen`5BX,y`5D := '`7E';
  205. XFor Y := 1 To Screen_Dim_Y do Begin
  206. X   Screen`5B1,Y`5D := 'q';
  207. X   Screen`5BScreen_Dim_X,Y`5D := 'q';
  208. Xend;
  209. XFor X := 1 To Screen_Dim_X Do Begin
  210. X   Screen`5BX,1`5D := 'x';
  211. X   Screen`5BX,Screen_Dim_Y`5D := 'x';`20
  212. Xend;
  213. XScreen`5B1,1`5D := 'l';
  214. XScreen`5B1,Screen_Dim_Y`5D := 'k';
  215. XScreen`5BScreen_Dim_X,1`5D := 'm';
  216. XScreen`5BScreen_Dim_X,Screen_Dim_y`5D := 'j';
  217. XHead_Sym`5B1`5D := chr(128+ord('1'));  `7B Set The Bits In The Chars `7D
  218. XHead_Sym`5B2`5D := chr(128+ord('2'));
  219. XHead_Sym`5B3`5D := chr(128+ord('3'));
  220. XHead_Sym`5B4`5D := chr(128+ord('4'));
  221. XHead_Sym`5B5`5D := chr(128+ord('5'));
  222. XHead_Sym`5B6`5D := chr(128+ord('6'));
  223. XHead_Sym`5B7`5D := chr(128+ord('7'));
  224. XHead_Sym`5B8`5D := chr(128+ord('8'));
  225. X
  226. XFor Play := 1 to Max_Num_PLayers do`20
  227. X   If Not Quit`5Bplay`5D Then`20
  228. X      Screen`5BHead_X`5BPlay`5D,Head_Y`5BPlay`5D`5D := 'O';
  229. X`7B Note If This Procedure Is Only Called When You Are Master Snake`20
  230. X  Draw Screen Should Be In The Mainlkine Before Init_pos
  231. X  And The Writing Of The PLayers Pos Should Be To The Buffer`20
  232. X  And Then Written To All Who Are PLaying `7D
  233. X
  234. XDraw_screen;  `20
  235. X
  236. X`7B Pos Inital Player Positions `7D
  237. XFor Play := 1 to Max_Num_PLayers do `20
  238. X   If ( Not Quit`5BPlay`5D  ) Then `20
  239. X      Writeln(at(Head_X`5BPlay`5D,Head_Y`5BPlay`5D),Head_sym`5BPlay`5D);
  240. Xend;
  241. X
  242. XProcedure Initalise_Mainline;
  243. X
  244. XVar Zero,Init_Rep,PLay,Name_pos,Game_Going : Integer;
  245. X
  246. XProcedure Verify_name(VAr Name : Name_Line );
  247. X
  248. XVar I : INteger;
  249. X
  250. X
  251. XBegin
  252. X   For I := 1 to Max_Name_length do   `7B Remove All Invalid Chars From The
  253. V Name`7D
  254. X      If ( Name`5Bi`5D < ' ' ) or ( Name`5Bi`5D > '`7E' ) Then Begin
  255. X            Write(chr(7));
  256. X            Name`5Bi`5D := ' ';
  257. X      end;
  258. Xend;
  259. X
  260. X
  261. XBegin
  262. X   Esc := Chr(27);
  263. X   Seed := Clock;
  264. X   TT_Len := 0;
  265. X  `20
  266. X
  267. X   `7B set where Each Player Starts `7D
  268. X
  269. X   Init_pos_X`5B1`5D := 2;
  270. X   Init_pos_Y`5B1`5D := 2;
  271. X  `20
  272. X   Init_pos_X`5B2`5D := Screen_dim_x - 1;
  273. X   Init_pos_Y`5B2`5D := Screen_dim_Y - 1;
  274. X  `20
  275. X   Init_pos_X`5B3`5D := 2;
  276. X   Init_pos_Y`5B3`5D := Screen_dim_y - 1;
  277. X  `20
  278. X   Init_pos_X`5B4`5D := Screen_dim_x - 1;
  279. X   Init_pos_Y`5B4`5D := 2;
  280. X  `20
  281. X   Init_pos_X`5B5`5D := 2;
  282. X   Init_pos_Y`5B5`5D := Screen_dim_Y div 2;
  283. X  `20
  284. X   Init_pos_X`5B6`5D := Screen_dim_x - 1 ;
  285. X   Init_pos_Y`5B6`5D := Screen_dim_Y div 2;
  286. X  `20
  287. X   Init_pos_X`5B7`5D := Screen_dim_x div 2;
  288. X   Init_pos_Y`5B7`5D := 2;
  289. X  `20
  290. X   Init_pos_X`5B8`5D := Screen_dim_x div 2;
  291. X   Init_pos_Y`5B8`5D := Screen_dim_Y - 1;
  292. X
  293. X   Writeln(Esc,'<'); `7B Vt52 Mode `7D
  294. X   Writeln(Esc,'`5B1;1H',Esc,'`5BJ');    `7B Clear Screen `7D
  295. X   Init_rep := Snake_Init(You,Game_going);
  296. X   You := You + 1;  `20
  297. X   If Init_rep = 1 Then Begin
  298. X      `7B you are the First Person to play zero all the scores `7D
  299. X      For Play := 1 to Max_Num_PLayers do begin
  300. X         Zero := 0;
  301. X         Score_Set(Play,Zero,zero,zero);
  302. X      end;
  303. X      Help_Screen;
  304. X      Writeln(esc,'`5B1;1H',Esc,'`5B?2l');
  305. X      Writeln(at(22,3),' Please Enter Your Name Player #',You:1);
  306. X      Write(at(22,51));
  307. X      Readln(Name`5BYou`5D);
  308. X      Verify_Name(Name`5BYou`5D);
  309. X      Name_set(Name`5BYou`5D);
  310. X      Write(at(22,3), ' Hit < Return > When Others Ready   ');
  311. X      Readln;
  312. X      Writeln;
  313. X      Write(at(22,3), ' Please Wait For Game To Start      ');
  314. X      Writeln;
  315. X   end Else Begin
  316. X      If You = 0 Then Begin
  317. X         Writeln(esc,'`5B1;18H',Esc,'#3SNAKE');
  318. X         Writeln(esc,'`5B2;18H',Esc,'#4SNAKE');
  319. X         Writeln(esc,'`5B4;8H' ,Esc,'#6Sorry No Snakes Available');
  320. X`09 Sleep(3);
  321. X         goto 9999;
  322. X      end else begin `7B Init_rep = 0 `7D`20
  323. X         Help_Screen;
  324. X         Writeln(esc,'`5B1;1H',Esc,'`5B?2l');
  325. X         Writeln(at(22,3),' Please Enter Your Name Player # ',You:1);
  326. X         Write(at(22,51));
  327. X         Readln(Name`5BYou`5D);
  328. X         Verify_name(Name`5BYou`5D);
  329. X         Name_set(Name`5BYou`5D);
  330. X         Writeln;
  331. X         Write(at(22,3), ' Please Wait For Game To Start     ');
  332. X         Writeln;
  333. X         If Game_Going = 1 Then`20
  334. X            Snake_Game_End;
  335. X      end;
  336. X   end;
  337. X   Game`5BYou`5D := 0;
  338. Xend `7B Initalise Mainline `7D;
  339. X
  340. XFunction Correct_Sym(Last_Move_X,Last_Move_Y,Move_X,Move_Y:Integer):Char;
  341. X
  342. XBegin  `7B Calculates The Correct symbol To Write Given The Dir You Were In
  343. V `7D
  344. X    Case (Last_Move_X+1) + (Last_Move_Y+1)*4 Of`20
  345. X      6 : `7B Down `7D
  346. X             Case (Move_X+1) + (Move_Y+1)*4 Of`20
  347. X               6 : `7B Down `7D
  348. X                   Correct_Sym := 'x';
  349. X               9 : `7B Right `7D
  350. X                   Correct_Sym := 'm';
  351. X               1 : `7B Left `7D
  352. X                   Correct_Sym := 'j';
  353. X               4 : `7B Up Note : This Is Poss On First Move `7D
  354. X                   Correct_Sym := 'x';
  355. X               end `7B Case `7D;
  356. X      4 : `7B Up `7D
  357. X             Case (Move_X+1) + (Move_Y+1)*4 Of`20
  358. X               6 : `7B Down `7D
  359. X                   Correct_Sym := 'x';
  360. X               4 : `7B Up `7D
  361. X                   Correct_Sym := 'x';              `20
  362. X               9 : `7B Right `7D
  363. X                   Correct_Sym := 'l';
  364. X               1 : `7B Left `7D
  365. X                   Correct_Sym := 'k';  `20
  366. X               end `7B Case `7D;
  367. X     `20
  368. X      9 : `7B Right `7D
  369. X             Case (Move_X+1) + (Move_Y+1)*4 Of`20
  370. X               6 : `7B Down `7D
  371. X                   Correct_Sym := 'k';              `20
  372. X               4 : `7B Up `7D
  373. X                   Correct_Sym := 'j';              `20
  374. X               9 : `7B Right `7D
  375. X                   Correct_Sym := 'q';
  376. X               1 : `7B Left `7D
  377. X                   Correct_Sym := 'q';  `20
  378. X               end `7B Case `7D;
  379. X
  380. X      1 : `7B Left `7D
  381. X             Case (Move_X+1) + (Move_Y+1)*4 Of`20
  382. X               9 : `7B Right `7D
  383. X                   Correct_Sym := 'q';
  384. X               6 : `7B Down `7D
  385. X                   Correct_Sym := 'l';              `20
  386. X               4 : `7B Up `7D
  387. X                   Correct_Sym := 'm';              `20
  388. X               1 : `7B Left `7D
  389. X                   Correct_Sym := 'q';  `20
  390. X               end `7B Case `7D;
  391. X
  392. X      end `7B Case `7D;
  393. Xend; `7B Correct Sym `7D
  394. X
  395. X`5BGLOBAL`5D Function Add_head( Var Responce : Player_responce ):Integer;
  396. X
  397. XVar Play, Num_Moved, Dir_X, Dir_Y, Pos_x, Pos_Y : Integer;
  398. X
  399. X
  400. X
  401. XProcedure Remove_tail( Var STail_X , STail_Y : Integer );
  402. X
  403. XVar Last_X,Last_Y : Integer;
  404. X
  405. XBegin `7B removes the Tail of the snake whose tail is at StailX,Y `7D
  406. X`7B The Character To Move is determined by the Char at the tail
  407. X  and if a character joins up to it `7D
  408. X
  409. X      Last_X := STail_X;
  410. X      Last_Y := STail_Y;
  411. X      Pos(STail_X,STail_Y,'`7E');
  412. X      Case Screen`5BSTail_X,STail_Y`5D  of`20
  413. X         'l' : If Screen`5BStail_X,STail_Y+1`5D In `5B'k','j','q'`5D Then`20
  414. X                  STail_Y := STail_Y + 1
  415. X               Else
  416. X                  STail_X := STail_X + 1;
  417. X         'k' : If Screen `5BSTail_X,STail_Y-1`5D In `5B'l','m','q'`5D Then`2
  418. V0
  419. X                  STail_Y := STail_Y - 1
  420. X               Else
  421. X                  Stail_X := STail_X + 1 ;
  422. X         'm' : If Screen`5BSTail_X,STail_Y+1`5D In `5B'k','j','q'`5D Then
  423. X                  Stail_Y := STail_Y + 1
  424. X               Else
  425. X                  Stail_X := Stail_X - 1 ;
  426. X         'j' : If Screen`5BSTail_X,STail_Y-1`5D In `5B'm','l','q'`5D Then`20
  427. X                  STail_Y := STail_Y - 1
  428. X               Else
  429. X                  STail_X := STail_X - 1;
  430. X         'x' : If Screen`5BSTail_X-1,STail_Y`5D In `5B'l','k','x'`5D Then`20
  431. X                  STail_X := STail_X - 1
  432. X               Else
  433. X                  STail_X := STail_X + 1;
  434. X         'q' : If Screen`5BSTail_X,STail_Y - 1 `5D In `5B 'l','m','q'`5D The
  435. Vn`20
  436. X                  STail_Y := STail_Y - 1
  437. X               Else
  438. X                  STail_Y := STail_Y + 1;
  439. X         end `7B CAse `7D;
  440. X      Screen`5BLast_X,Last_Y`5D := '`7E';
  441. Xend `7B remove_Tail`7D;
  442. X
  443. X
  444. XProcedure Remove_Players_tail( play : Integer );
  445. X
  446. XVar X,Y : Integer;
  447. X
  448. XBegin   `7B Removed Odd Players Tails Of Play = 1 Even If 2 `7D
  449. X   While Play <= Max_PLayer_Number do Begin
  450. X      If Not Died`5BPlay`5D Then `20
  451. X         Remove_tail(Tail_X`5BPLay`5D,Tail_Y`5BPLay`5D);
  452. X      Play := Play + 2;
  453. X   end;
  454. Xend;
  455. X
  456. X
  457. XProcedure Add_This_Players_Head;
  458. X
  459. Xbegin
  460. X   If Not Quit`5BPlay`5D And (Ord(Responce`5BPLay`5D) = 0 )  Then begin
  461. X      Died`5BPLay`5D := True;      `7B If PLayer quit Then`20
  462. X      Quit`5BPLay`5D := True;         Initalise all Variables `7D
  463. X      Game`5BPlay`5D := 0;
  464. X      Score`5BPlay`5D := 0;
  465. X      Games_Won`5BPLay`5D := 0;
  466. X      Score_Set(Play,Score`5BPlay`5D,Game`5BPLay`5D,Games_Won`5BPLay`5D);
  467. X   end else`20
  468. X      If Not Died`5BPlay`5D  Then Begin
  469. X         Dir_X := Move_X`5BPlay`5D;
  470. X         Dir_Y := Move_Y`5BPLay`5D;
  471. X`09 Pos_X := Head_X`5BPlay`5D;
  472. X         Pos_Y := Head_Y`5BPlay`5D;
  473. X         `7B Change Direction Of The Position You Move To is Not A Wall ie =
  474. V '.' `7D
  475. X         Case Ord(responce`5BPlay`5D) Of`20
  476. X            8 : If Screen`5BPos_x-1,Pos_Y`5D = '`7E' Then  Begin
  477. X                     Dir_X := -1 ;
  478. X                     Dir_Y := 0 ;      `7B Moving Up `7D
  479. X                  end;
  480. X            2 : If Screen`5BPos_X+1,Pos_Y`5D = '`7E' Then Begin
  481. X                     Dir_X := 1;
  482. X                     Dir_Y := 0;         `7B Moving Down `7D
  483. X                  end;
  484. X            4 : If Screen`5BPos_X,Pos_Y-1`5D = '`7E' Then Begin
  485. X                     Dir_X := 0;          `7B Moving Left `7D
  486. X                     Dir_Y := -1;
  487. X                  end;
  488. X            6 : If Screen`5BPos_X,Pos_Y+1`5D = '`7E' Then Begin
  489. X                     Dir_X := 0;            `7B Moving Right `7D
  490. X                     Dir_Y := 1;
  491. X                  end;
  492. X            otherwise `7B Do Nothing Same Dir As Before `7D
  493. X         end `7B Case `7D;
  494. X         `7B Given LAst Direction Or New Direction `7D
  495. X         If Screen`5BPos_X + Dir_X , Pos_Y + Dir_Y `5D = '`7E' Then Begin `2
  496. V0
  497. X`09    `7B Going into a Blank square ok to move `7D
  498. X            Num_Moved := Num_Moved + 1;
  499. X            Screen`5BPos_X ,Pos_Y `5D :=`20
  500. X                  Correct_sym(Move_X`5BPlay`5D,Move_Y`5BPLay`5D,Dir_X,Dir_Y)
  501. V;
  502. X            pos(Pos_X,Pos_Y,Screen`5BPos_X,Pos_Y`5D);
  503. X            Pos_X := Pos_X + Dir_X;
  504. X            Pos_Y := Pos_Y + Dir_Y;
  505. X            Screen`5BPos_X,Pos_Y`5D :=  'O';
  506. X            Pos(Pos_X,Pos_Y,Head_Sym`5BPLay`5D);
  507. X         end else begin `7B You HAve Died Hit Into A Non Blank Square `7D
  508. X            Died`5BPlay`5D := True;
  509. X            If Num_PLayers <> Num_Moved_Last_Round Then `20
  510. X               Score`5BPlay`5D := Score`5BPlay`5D +`20
  511. X                     (( Num_PLayers - Num_Moved_Last_Round  + 1 )**2 * 100 )
  512. V`20
  513. X                        div ( NUm_Players**2);
  514. X            pos(Pos_X,Pos_Y,Correct_sym(Move_X`5BPlay`5D,Move_Y`5BPLay`5D,Di
  515. Vr_X,Dir_Y));
  516. X            Pos_X := Pos_X + Dir_X;
  517. X            Pos_Y := Pos_Y + Dir_Y;
  518. X`09    Snake_Dead(play);`20
  519. X         end;
  520. X         Move_X`5BPlay`5D := Dir_X;
  521. X         Move_Y`5BPLay`5D := Dir_Y;
  522. X`09 Head_X`5BPlay`5D := pos_X;
  523. X         Head_Y`5BPlay`5D := Pos_Y;
  524. X      end;
  525. Xend;
  526. X
  527. Xbegin
  528. X   Num_Moved := 0;            `7B Iniotalise Counter For The Number Who Move
  529. Vd `7D
  530. X   If Players_reMoving = 1 Then Begin      `7B If 1 Then Loop Clockwise `7D
  531. X      For Play := 1 to Max_Player_number do`20
  532. X         add_This_Players_head;
  533. X      Remove_players_tail(1);               `7B Remove Odd Players Tail `7D
  534. X      PLayers_ReMoving := 2;                `7B Next Round Shall remove Even
  535. V Ones `7D
  536. X   end else`20
  537. X      If Players_removing = 2 Then Begin
  538. X         For Play := Max_Player_Number downto 1 do`20
  539. X            add_This_Players_head;               `7B Go Clockwise In Updatin
  540. Vg `7D
  541. X         Remove_Players_tail(2);
  542. X         PLayers_ReMoving := 1;
  543. X      end else begin
  544. X         For Play := Max_Player_Number downto 1 do `7B First Few Moves Don't
  545. V remove Tail `7D
  546. X            add_This_Players_head;               `7B Go Clockwise In Updatin
  547. Vg `7D
  548. X         Players_removing := Players_removing + 1;
  549. X      end;
  550. X   If Num_Moved <= 1 Then Begin                  `7B Ie There IS Only 1 or 0
  551. V PLayers Left `7D
  552. X      For PLay := 1 to Max_player_Number do Begin
  553. X`09If Not Quit`5BPlay`5D Then Begin
  554. X            If Not Died`5BPLay`5D Then Begin
  555. X               Score`5BPLay`5D := Score`5BPlay`5D + 100;    `7B One Hundred
  556. V If You Last Left `7D
  557. X               Games_Won`5BPLay`5D := Games_Won`5BPLay`5D + 1;
  558. X            end;
  559. X            Score_set(Play,Score`5BPlay`5D,Game`5BPlay`5D,Games_Won`5BPLay`5
  560. VD);
  561. X         end;
  562. X       end;
  563. X      Add_head := 0;            `7B Return 0 To Stop The Game `7D
  564. X   end else`20
  565. X      Add_Head := 1;            `7B 1 To Comtinue `7D
  566. X   Num_Moved_Last_Round := Num_Moved;
  567. X   Break_Buff;    `7B does not write the buffer just says To`20
  568. X                   Write this buffer to all the players when add_head exits
  569. V `7D
  570. Xend `7B add_Head`7D;
  571. X
  572. X
  573. XProcedure Snake_PLay;extern;
  574. X
  575. X
  576. XBegin `7B Mainline `7D
  577. X   LineLimit(Output,MaxInt);
  578. X   Initalise_Mainline;
  579. X   While True Do Begin
  580. X      Initalise_Positions;      `7B initalises pos Only relavent for master
  581. V snake `7D
  582. X      Snake_Play;               `7B Calls Add_head with the Moves of the pla
  583. Vyers  until add_head returns 1 ( end of game ) `7D
  584. X      Draw_Scores;
  585. X      Snake_Game_End;           `7B Syncs all players Together `7D
  586. X   end;
  587. X9999 :`20
  588. X  Writeln(esc,'<');
  589. Xend.
  590. $ CALL UNPACK SNAKEP.PAS;4 141985560
  591. $ v=f$verify(v)
  592. $ EXIT
  593.